<%@ include file="connect.jsp" %>
<%--
  Created by IntelliJ IDEA.
  User: Mery
  Date: 10/25/12
  Time: 11:03 PM
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    if (session.getAttribute("namaUser") == null) {

        response.sendRedirect("login.jsp?respon=You have to login first!");
    }

%>

<html>
<head>
    <title>Business English</title>
    <link href="style.css" rel="stylesheet"/>
    <script type="text/javascript" language="javascript">
        function confirmAction() {
            var confirmed = confirm("Are you sure want to delete this case?");
            return confirmed;
        }
    </script>
    <script src="jquery.js" type="text/javascript"></script>
    <script src="facebox.js" type="text/javascript"></script>
    <script type="text/javascript">
        jQuery(document).ready(function ($) {
            $('a[rel*=facebox]').facebox({
                loadingImage:'images/loading.gif',
                closeImage:'images/closelabel.png'
            })
        })
    </script>
</head>

<body>
<table id="bg" cellspacing="0">
    <tr id="header">

        <td class="link">
            <%@ include file="header.jsp" %>
        </td>
    </tr>
    <tr id="menu">
        <td>
            <%@ include file="menu.jsp" %>
        </td>
    </tr>
    <tr id="hr">
        <td><hr width="100%" size="8" noshade="noshade" ></td>
    </tr>
    <tr id="content">
        <td class="link" valign="top" style="padding-left: 20px">

            <table>
                <tr id="title">
                    <td>Games</td>
                </tr>
                <tr>
                    <td>
                        <div class="btn-fld"><a id="games" rel="facebox" href="AddNewCase.jsp">
                            <button type="button">Add New Case</button>
                        </a>
                        </div>
                    </td>
                </tr>
                <table>
                    <tr id="warning">
                        <td>

                            <%
                                String respon = request.getParameter("respon");

                                if (respon != null) {

                                    out.print(respon);
                            %>
                            <% } %>

                        </td>
                    </tr>
                </table>
                <table width="600px" border="2" id="bor1">

                    <tr style="text-align: center; font-weight: 600">
                        <td width="12px">No</td>
                        <td>Case's Name</td>

                        <td width="20px">Action</td>
                    </tr>

                    <tr>
                        <%
                            int i = 0;
                            ResultSet rs = stat.executeQuery
                                    ("select * from Games");
                            while (rs.next()) {
                                i = i + 1;
                                String id = rs.getString("gamesID");
                        %>
                        <td align="center"><%=i%>
                        </td>
                        <td><%out.print(rs.getString("gamesName"));%></td>

                        <td style="text-align: center">
                            <a href="UpdateCase.jsp?id=<%=id%>" rel="facebox"> <img height="25px" src="edit.png"
                                                                                    title="Update Case"></a>&nbsp;&nbsp;
                            <a href="showQuestion.jsp?id=<%=id%>"><img height="25px" src="search_folder.png"
                                                                       title="Show Question"></a>&nbsp;&nbsp;
                            <a href="doDeleteCase.jsp?id=<%out.print(rs.getString("gamesID"));%>&nama=<%out.print(rs.getString("gamesName"));%>"
                               onclick="return confirmAction()"><img height="25px" src="Delete.png" title="Delete Case"></a>
                        </td>
                    </tr>

                    <% } %>

                </table>


            </table>
        </td>
    </tr>

</table>
</body>
</html>